#!/bin/bash

mkdir -p result

SO_FILES=$(ls *.so 2>/dev/null)

if [ -z "$SO_FILES" ]; then
    exit 1
fi

for SO_FILE in $SO_FILES; do
    OUTPUT_FILE="result/${SO_FILE}.txt"
    echo "[$SO_FILE]" > "$OUTPUT_FILE"
    nm -D "$SO_FILE" 2>/dev/null | awk '{print $2, $3}' >> "$OUTPUT_FILE"
    echo "" >> "$OUTPUT_FILE"
done

echo "SUCCESS"